
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>FindOpenSSL &mdash; CMake 3.27.4 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/sphinx_highlight.js"></script>
    
    <link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindOpenThreads" href="FindOpenThreads.html" />
    <link rel="prev" title="FindOpenSP" href="FindOpenSP.html" />
 

  </head><body>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="FindOpenThreads.html" title="FindOpenThreads"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="FindOpenSP.html" title="FindOpenSP"
             accesskey="P">previous</a> |</li>
  <li>
    <img src="../_static/cmake-logo-16.png" alt=""
         style="vertical-align: middle; margin-top: -2px" />
  </li>
  <li>
    <a href="https://cmake.org/">CMake</a> &#187;
  </li>
  <li>
    <a href="../index.html">3.27.4 Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindOpenSSL</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="findopenssl">
<span id="module:FindOpenSSL"></span><h1>FindOpenSSL<a class="headerlink" href="#findopenssl" title="Permalink to this heading">¶</a></h1>
<p>Find the OpenSSL encryption library.</p>
<p>This module finds an installed OpenSSL library and determines its version.</p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.19: </span>When a version is requested, it can be specified as a simple value or as a
range. For a detailed description of version range usage and capabilities,
refer to the <span class="target" id="index-0-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_package()</span></code></a> command.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.18: </span>Support for OpenSSL 3.0.</p>
</div>
<section id="optional-components">
<h2>Optional COMPONENTS<a class="headerlink" href="#optional-components" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.12.</span></p>
</div>
<p>This module supports two optional COMPONENTS: <code class="docutils literal notranslate"><span class="pre">Crypto</span></code> and <code class="docutils literal notranslate"><span class="pre">SSL</span></code>.  Both
components have associated imported targets, as described below.</p>
</section>
<section id="imported-targets">
<h2>Imported Targets<a class="headerlink" href="#imported-targets" title="Permalink to this heading">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.4.</span></p>
</div>
<p>This module defines the following <span class="target" id="index-0-prop_tgt:IMPORTED"></span><a class="reference internal" href="../prop_tgt/IMPORTED.html#prop_tgt:IMPORTED" title="IMPORTED"><code class="xref cmake cmake-prop_tgt docutils literal notranslate"><span class="pre">IMPORTED</span></code></a> targets:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL::SSL</span></code></dt><dd><p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">ssl</span></code> library, if found.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL::Crypto</span></code></dt><dd><p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">crypto</span></code> library, if found.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OpenSSL::applink</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">New in version 3.18.</span></p>
</div>
<p>The OpenSSL <code class="docutils literal notranslate"><span class="pre">applink</span></code> components that might be need to be compiled into
projects under MSVC. This target is available only if found OpenSSL version
is not less than 0.9.8. By linking this target the above OpenSSL targets can
be linked even if the project has different MSVC runtime configurations with
the above OpenSSL targets. This target has no effect on platforms other than
MSVC.</p>
</dd>
</dl>
<p>NOTE: Due to how <code class="docutils literal notranslate"><span class="pre">INTERFACE_SOURCES</span></code> are consumed by the consuming target,
unless you certainly know what you are doing, it is always preferred to link
<code class="docutils literal notranslate"><span class="pre">OpenSSL::applink</span></code> target as <code class="docutils literal notranslate"><span class="pre">PRIVATE</span></code> and to make sure that this target is
linked at most once for the whole dependency graph of any library or
executable:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">target_link_libraries(</span><span class="nb">myTarget</span><span class="w"> </span><span class="no">PRIVATE</span><span class="w"> </span><span class="nb">OpenSSL</span><span class="o">::</span><span class="nb">applink</span><span class="nf">)</span>
</pre></div>
</div>
<p>Otherwise you would probably encounter unexpected random problems when building
and linking, as both the ISO C and the ISO C++ standard claims almost nothing
about what a link process should be.</p>
</section>
<section id="result-variables">
<h2>Result Variables<a class="headerlink" href="#result-variables" title="Permalink to this heading">¶</a></h2>
<p>This module will set the following variables in your project:</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_FOUND</span></code></dt><dd><p>System has the OpenSSL library. If no components are requested it only
requires the crypto library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_INCLUDE_DIR</span></code></dt><dd><p>The OpenSSL include directory.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_CRYPTO_LIBRARY</span></code></dt><dd><p>The OpenSSL crypto library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_CRYPTO_LIBRARIES</span></code></dt><dd><p>The OpenSSL crypto library and its dependencies.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_SSL_LIBRARY</span></code></dt><dd><p>The OpenSSL SSL library.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_SSL_LIBRARIES</span></code></dt><dd><p>The OpenSSL SSL library and its dependencies.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_LIBRARIES</span></code></dt><dd><p>All OpenSSL libraries and their dependencies.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_VERSION</span></code></dt><dd><p>This is set to <code class="docutils literal notranslate"><span class="pre">$major.$minor.$revision$patch</span></code> (e.g. <code class="docutils literal notranslate"><span class="pre">0.9.8s</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_APPLINK_SOURCE</span></code></dt><dd><p>The sources in the target <code class="docutils literal notranslate"><span class="pre">OpenSSL::applink</span></code> that is mentioned above. This
variable shall always be undefined if found openssl version is less than
0.9.8 or if platform is not MSVC.</p>
</dd>
</dl>
</section>
<section id="hints">
<h2>Hints<a class="headerlink" href="#hints" title="Permalink to this heading">¶</a></h2>
<p>The following variables may be set to control search behavior:</p>
<dl>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_ROOT_DIR</span></code></dt><dd><p>Set to the root directory of an OpenSSL installation.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_USE_STATIC_LIBS</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">New in version 3.4.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">TRUE</span></code> to look for static libraries.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">OPENSSL_MSVC_STATIC_RT</span></code></dt><dd><div class="versionadded">
<p><span class="versionmodified added">New in version 3.5.</span></p>
</div>
<p>Set to <code class="docutils literal notranslate"><span class="pre">TRUE</span></code> to choose the MT version of the lib.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">ENV{PKG_CONFIG_PATH}</span></code></dt><dd><p>On UNIX-like systems, <code class="docutils literal notranslate"><span class="pre">pkg-config</span></code> is used to locate the system OpenSSL.
Set the <code class="docutils literal notranslate"><span class="pre">PKG_CONFIG_PATH</span></code> environment variable to look in alternate
locations.  Useful on multi-lib systems.</p>
</dd>
</dl>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3><a href="../index.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#">FindOpenSSL</a><ul>
<li><a class="reference internal" href="#optional-components">Optional COMPONENTS</a></li>
<li><a class="reference internal" href="#imported-targets">Imported Targets</a></li>
<li><a class="reference internal" href="#result-variables">Result Variables</a></li>
<li><a class="reference internal" href="#hints">Hints</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="FindOpenSP.html"
                          title="previous chapter">FindOpenSP</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="FindOpenThreads.html"
                          title="next chapter">FindOpenThreads</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/module/FindOpenSSL.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="FindOpenThreads.html" title="FindOpenThreads"
             >next</a> |</li>
        <li class="right" >
          <a href="FindOpenSP.html" title="FindOpenSP"
             >previous</a> |</li>
  <li>
    <img src="../_static/cmake-logo-16.png" alt=""
         style="vertical-align: middle; margin-top: -2px" />
  </li>
  <li>
    <a href="https://cmake.org/">CMake</a> &#187;
  </li>
  <li>
    <a href="../index.html">3.27.4 Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">FindOpenSSL</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2000-2023 Kitware, Inc. and Contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.3.0.
    </div>
  </body>
</html>